package com.zb.dao.ext.base;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Repository;

import com.zb.dao.base.OmsCommonDao;
import com.zb.entity.base.OmsDeviceType;
import com.zb.entity.exception.OmsDaoException;
import com.zb.util.SequenceGenerator;

import java.util.Date;

/**
 * 设备型号数据操作类
 *
 * @author huanghao
 */
@Repository
public class OmsDeviceTypeDao extends OmsCommonDao<OmsDeviceType>
{

	public void updateByRId(String id) throws OmsDaoException
	{
		int flag = 0;
		try
		{
			flag = this.getJdbcTemplate().update("update oms_device_type set valid_flag = 0 where factory_id = ?", id);
		}
		catch (Exception e)
		{
			throw new OmsDaoException(e.getMessage(), e);
		}
		if (flag < 0)
		{
			throw new OmsDaoException("update fail");
		}
	}

//	public String insertOrUpdate(OmsDeviceType device) throws OmsDaoException
//	{
//		if (StringUtils.isEmpty(device.getFactory_id()) || StringUtils.isEmpty(device.getDev_type1()) || StringUtils.isEmpty(device.getDev_type2()))
//			throw new OmsDaoException("empty values");
//
//		OmsDeviceType q = this.findOneExampleByCondition(new OmsDeviceType(),
//				String.format(" WHERE valid_flag = 1 AND factory_id = '%1$s' AND dev_type1 = '%2$s' AND dev_type2 = '%3$s'  ", device.getFactory_id(), device.getDev_type1(), device.getDev_type2()));
//
//		String device_id = "";
//		if (q == null)
//		{
//			throw
//		}
//		else
//		{
//			device_id = q.getDevice_id();
//			q.setFactory_id(device.getFactory_id());
//			q.setDev_type1(device.getDev_type1());
//			q.setDev_type2(device.getDev_type2());
//			q.setUpdate_time(new Date());
//			q.setUpdate_oper_id("oms");
//			update(q);
//		}
//		return device_id;
//	}

}
